package com.alisoft.nano.seda;


/**
 * The event which wraps necessary information and work unit that processed by the stages.
 * 
 * @author zhimin.chenzm, anping.yinap
 *
 * @param <T>
 */
public class Event<T> {


    private T workUnit;
	private String nextStage;
	private String currentStage;
	private Throwable exception = null;
	
	
	private long startTime = 0;
	private long endTime = 0;
	private long startUserCPUTime = 0;
	private long endUserCPUTime = 0;
	
	
	
	public Event() {
	}

	public Event(T workUnit) {
		super();
		this.workUnit = workUnit;
	}

	public Event(T workUnit, String nextStage) {
		super();
		this.workUnit = workUnit;
		this.nextStage = nextStage;
	}

	public T getWorkUnit() {
		return workUnit;
	}

	public String getNextStage() {
		return nextStage;
	}

	public void setNextStage(String nextStage) {
		this.nextStage = nextStage;
	}

	public void setWorkUnit(T workUnit) {
		this.workUnit = workUnit;
	}

	public Throwable getException() {
		return exception;
	}

	public void setException(Throwable exception) {
		this.exception = exception;
	}	

	public void setCurrentStage(String currentStage) {
		this.currentStage = currentStage;
	}

	public String getCurrentStage() {
		return currentStage;
	}
   
    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }


    public long getStartUserCPUTime() {
        return startUserCPUTime;
    }

    public void setStartUserCPUTime(long startUserCPUTime) {
        this.startUserCPUTime = startUserCPUTime;
    }

    public long getEndUserCPUTime() {
        return endUserCPUTime;
    }

    public void setEndUserCPUTime(long endUserCPUTime) {
        this.endUserCPUTime = endUserCPUTime;
    }
    
    public long getUserCPUTime() {
        return this.endUserCPUTime - this.startUserCPUTime;
    }
    
    public long getRunTime() {
        return this.endTime - this.startTime;
    }
    
}
